import 'dart:ui';

import 'base_text_config.dart';
import 'base_text_info.dart';

class ZZTextConfig extends BaseTextConfig {
  final String path;
  final double ratio;
  final Size? size;
  final String? id;
  final String textId;
  final BaseTextInfo? textInfo;

  ZZTextConfig(String text,
      {required this.path,
      required this.ratio,
      this.size,
      this.id,
      required this.textId,
      required this.textInfo})
      : super(text);

  factory ZZTextConfig.fromMap(Map<String, dynamic> map,
      {BaseTextInfo? Function(Map<String, dynamic>?)? createInfo}) {
    return ZZTextConfig(map['text'] ?? '',
        path: map['path'] ?? '',
        ratio: map['ratio'] ?? 0.0,
        textId: map['textId'] ?? '',
        textInfo: createInfo?.call(map['textInfo']));
  }

  Map<String, dynamic> toMap() {
    return {
      'text': text,
      'path': path,
      'textId': textId,
      'id': id,
      'ratio': ratio,
      'textInfo': textInfo
    };
  }
}
